<?php

namespace App\Store\Validate\Basic;

use App\Common\Validate\BaseValidate;

/**
 * 权限组验证器
 */
class GoodsCategory extends BaseValidate
{

    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];


    public function __construct($doaction = 'add')
    {
        if ($doaction == 'add') {
            $this->rule = [
                'store_ids'=>'required',
                'category_name'=>'required',
                'goods_cabinetgroup_id'=>'required',
                'goods_metal_id'=>'required',
                'is_recovery'=>'required|in:1,2',
                'is_sujin'=>'required|in:1,2',
                'is_virtually'=>'required|in:1,2',
                'is_maintenance_price'=>'required|in:1,2',
                'is_gram'=>'required|in:1,2',
            ];
            $this->message = [
                'store_ids.required' => '门店未选择',
                'category_name.required' => '类别名称不能为空',
                'goods_cabinetgroup_id.required' => '柜组未选择',
                'goods_metal_id.required' => '材质未选择',
                'is_recovery.required' => '是否回收未选择',
                'is_recovery.in' => '是否回收参数错误',
                'is_sujin.required' => '是否素金未选择',
                'is_sujin.in' => '是否素金参数错误',
                'is_virtually.required' => '是否虚拟商品未选择',
                'is_virtually.in' => '是否虚拟商品参数错误',
                'is_maintenance_price.required' => '是否维护金价未选择',
                'is_maintenance_price.in' => '是否维护金价参数错误',
                'is_gram.required' => '是否克算未选择',
                'is_gram.in' => '是否克算参数错误',

            ];
        } elseif ($doaction == 'edit') {
            $this->rule = [
                'id' => 'required|integer|gt:0',
                'category_name'=>'required',
                'goods_cabinetgroup_id'=>'required',
                'goods_metal_id'=>'required',
                'is_recovery'=>'required|in:1,2',
                'is_sujin'=>'required|in:1,2',
                'is_virtually'=>'required|in:1,2',
                'is_maintenance_price'=>'required|in:1,2',
                'is_gram'=>'required|in:1,2',
            ];
            $this->message = [
                'id.required' => '参数错误',
                'id.integer' => '参数错误',
                'id.gt' => '参数错误',
                'category_name.required' => '类别名称不能为空',
                'goods_cabinetgroup_id.required' => '柜组未选择',
                'goods_metal_id.required' => '材质未选择',
                'is_recovery.required' => '是否回收未选择',
                'is_recovery.in' => '是否回收参数错误',
                'is_sujin.required' => '是否素金未选择',
                'is_sujin.in' => '是否素金参数错误',
                'is_virtually.required' => '是否虚拟商品未选择',
                'is_virtually.in' => '是否虚拟商品参数错误',
                'is_maintenance_price.required' => '是否维护金价未选择',
                'is_maintenance_price.in' => '是否维护金价参数错误',
                'is_gram.required' => '是否克算未选择',
                'is_gram.in' => '是否克算参数错误',
            ];
        }
    }
}
